<template>
  <el-dialog title="导入详情" width="50%" :visible.sync="dialogData.isShow">
    <div class="table-conBtn">
      <freshCom @searchList="searchList"></freshCom>
    </div>
    <!-- 表格部分 -->
    <el-table :data="tableData" max-height="600">
      <el-table-column label="编号" type="index" width="120" align="center">
      </el-table-column>
      <el-table-column
        label="操作人"
        prop="createUserName"
        min-width="80"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="操作时间"
        prop="createTime"
        min-width="80"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="导入状态"
        min-width="80"
        align="center"
        :formatter="formatter"
      >
      </el-table-column>
      <el-table-column label="导入结果" min-width="130" align="center">
        <template slot-scope="{ row }" v-if="row.status === 'STOP'">
          成功上传
          {{ row.importInfo.successNum }} 条AB用户openID关系，成功关联
          {{ row.importInfo.relationNum }} 条；未查到A的openID
          {{ row.importInfo.notFoundANum }} 条，未查到B的openID
          {{ row.importInfo.notFoundBNum }} 条；建立失败-关系已存在
          {{ row.importInfo.existNum }} 条，建立失败-B入量失败
          {{ row.importInfo.failNum }} 条
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页器 -->
    <pageCom
      :searchParams="searchParams"
      :total="total"
      @searchList="searchList"
    ></pageCom>
  </el-dialog>
</template>
<script>
import { importDetail } from '@/api/openIdRelationAB/openidUserRelation'
export default {
  props: ['dialogData'],
  data() {
    return {
      tableData: [],
      total: 0,
      searchParams: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  mounted() {
    this.searchList()
  },
  methods: {
    /* 获取列表 */
    searchList() {
      importDetail(this.searchParams, (res) => {
        this.tableData = res.rows
        this.total = res.total
      })
    },
    /* 格式化导入状态 */
    formatter(row) {
      switch (row.status) {
        case 'START':
          return '导入中'
        case 'STOP':
          return '导入完成'
        case 'ERROR':
          return '导入失败'
      }
    }
  }
}
</script>
<style lang="less" scoped>
:deep(.el-dialog) {
  margin: 5vh auto 0 !important;
}
</style>
